namespace GGF
{
    namespace API
    {
        using System;
        using System.Collections.Generic;
        using System.Diagnostics;


        /// <summary>
        /// Abstraction of a natural, individual user list.
        /// Currently only supports subset of API fields for this object.
        /// </summary>
        public class gList
        {
            #region Fields

            Dictionary<int, gActionItem> changedItems;
            
            Dictionary<int, gItem> listItems;            

            int list_id;
            string list_description;
            string list_name;

            #endregion Fields

            #region Constructors

            /// <summary>
            /// Constructor for a user list.
            /// </summary>
            /// <param name="id">An int representing the list's unique ID.</param>
            /// <returns>An object representing a gubb user list.</returns>
            public gList(int id)
            {
                list_id = id;
                listItems = new Dictionary<int, gItem>();
                changedItems = new Dictionary<int, gActionItem>();

                Debug.WriteLine("New list instantiated. id = " + id, "List creation");
            }

            #endregion Constructors

            #region Properties

            ///<summary>
            ///Gets or sets this list's description text.
            ///</summary>
            /// <value>
            /// A text description of this list, stored using a standard .NET string.
            /// </value>
            public string description
            {
                get { return list_description; }
                set { list_description = value; Debug.WriteLine("description modified for " + list_id, "List modification"); }
            }

            ///<summary>
            ///Gets or sets the list's standard name (not e-mail name).
            ///</summary>
            /// <value>
            /// The list's internal name as set by the user, stored using a standard
            /// string.
            /// </value>
            public string name
            {
                get { return list_name; }
                set { list_name = value; Debug.WriteLine("name modified for " + list_id, "List modification"); }
            }

            #endregion Properties

            #region Methods

            /// <summary>
            /// Adds an item to the list.
            /// <remarks>
            /// This method used to populate list with pre-existing items (those
            /// sent as the result of an API request/response).
            /// These items are added to the list's generic <c>listItems</c>
            /// collection member.
            /// </remarks>
            /// </summary> 
            /// <param name="item">A <see cref="GGF.API.gItem" /> set with
            /// desired values per the user.</param>
            /// <returns>Nothing. See remarks.</returns>
            public void addItem(gItem item)
            {
                listItems.Add(item.getItemId(), item);
             
                Debug.WriteLine("Item added to list with item id" + item.getItemId(), "List modification");
            }

            /// <summary>
            /// Changes an item that already exists in a list.
            /// <remarks>
            /// All changed items are added to the list's generic
            /// <c>changedItems</c> collection member. Changed items only held
            /// in memory after method completes - they have not yet been
            /// submitted to the API.
            /// </remarks>
            /// </summary>
            /// <param name="idOfItemToChange">An int representing the item's
            /// gubb-generated item ID.</param>
            /// <param name="actionToPerform">A <see cref="GGF.API.gActionItem"/> 
            /// that tells GGF what changes are to be made to this
            /// particular item.</param>
            /// <returns>Nothing. See remarks.</returns>
            public void changeItem(int idOfItemToChange, gActionItem actionToPerform)
            {
                changedItems.Add(idOfItemToChange, actionToPerform);

                Debug.WriteLine("Item marked for change in list " + list_id, "List modification");
            }

            #endregion Methods
        }
    }
}